package com.example.play.util;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @author wsl
 * @version 1.0
 * @date 2020/5/18
 * @description 这是路径转换工具
 */

public class PathUtils {


    /***
     *  路径转换
     */
    public static String pathToPath(String str) {
        String path = null;
        if ("\\".equals (File.separator)) {
            //windows下
            path = str + "\\";
        } else if ("/".equals (File.separator)) {
            //linux下
            path = str + "/";
        } else {
            path = str;
        }
        return path;
    }

    /**
     * 获取nio path
     *
     * @param str
     * @return
     */
    public static Path getPath(String str) {
        return Paths.get (pathToPath (str));
    }


}
